home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / xml4j.jar / com / ibm / xml / parser / GeneralReference.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-08-30  |  3.0 KB  |  119 lines

  1. package com.ibm.xml.parser;
  2.  
  3. import org.w3c.dom.DOMException;
  4. import org.w3c.dom.EntityReference;
  5. import org.w3c.dom.Node;
  6.  
  7. public class GeneralReference extends Parent implements EntityReference {
  8.    static final long serialVersionUID = 3555190050476479048L;
  9.    private String name;
  10.  
  11.    public GeneralReference(String var1) {
  12.       this.name = var1;
  13.    }
  14.  
  15.    public Object clone() {
  16.       return this.cloneNode(true);
  17.    }
  18.  
  19.    public synchronized Node cloneNode(boolean var1) {
  20.       ((Child)this).checkFactory();
  21.       GeneralReference var2 = (GeneralReference)super.factory.createEntityReference(this.getName());
  22.       if (var1) {
  23.          var2.children.ensureCapacity(super.children.getLength());
  24.  
  25.          for(int var3 = 0; var3 < super.children.getLength(); ++var3) {
  26.             ((Parent)var2).appendChild(super.children.item(var3).cloneNode(true));
  27.          }
  28.       }
  29.  
  30.       return var2;
  31.    }
  32.  
  33.    public synchronized boolean equals(Node var1, boolean var2) {
  34.       if (var1 == null) {
  35.          return false;
  36.       } else if (!(var1 instanceof GeneralReference)) {
  37.          return false;
  38.       } else {
  39.          GeneralReference var3 = (GeneralReference)var1;
  40.          if (!var3.getName().equals(this.getName())) {
  41.             return false;
  42.          } else {
  43.             return !var2 || var3.children.equals(super.children, var2);
  44.          }
  45.       }
  46.    }
  47.  
  48.    public short getNodeType() {
  49.       return 5;
  50.    }
  51.  
  52.    public String getNodeName() {
  53.       return this.getName();
  54.    }
  55.  
  56.    public String getName() {
  57.       return this.name;
  58.    }
  59.  
  60.    public String getLanguage() {
  61.       if (super.parent == null) {
  62.          return null;
  63.       } else if (super.parent instanceof TXElement) {
  64.          return ((TXElement)super.parent).getLanguage();
  65.       } else {
  66.          return super.parent instanceof GeneralReference ? ((GeneralReference)super.parent).getLanguage() : null;
  67.       }
  68.    }
  69.  
  70.    public void acceptPre(Visitor var1) throws Exception {
  71.       var1.visitGeneralReferencePre(this);
  72.    }
  73.  
  74.    public void acceptPost(Visitor var1) throws Exception {
  75.       var1.visitGeneralReferencePost(this);
  76.    }
  77.  
  78.    protected void checkChildType(Node var1) throws DOMException {
  79.       switch (var1.getNodeType()) {
  80.          case 1:
  81.          case 3:
  82.          case 4:
  83.          case 5:
  84.          case 7:
  85.          case 8:
  86.          case 23:
  87.             return;
  88.          default:
  89.             throw new TXDOMException((short)3, "Specified node type (" + var1.getNodeType() + ") can't be a child of EntityReference.");
  90.       }
  91.    }
  92.  
  93.    public void collectNamespaceAttributes() {
  94.       this.collectNamespaceAttributes(((Child)this).getParentNode());
  95.    }
  96.  
  97.    public void collectNamespaceAttributes(Node var1) {
  98.       if (((Child)this).getFactory().isProcessNamespace()) {
  99.          for(Node var2 = ((Parent)this).getFirstWithoutReference(); var2 != null; var2 = ((Child)var2).getNextWithoutReference()) {
  100.             if (var2.getNodeType() == 1) {
  101.                ((TXElement)var2).collectNamespaceAttributes(var1);
  102.             }
  103.          }
  104.  
  105.       }
  106.    }
  107.  
  108.    public void removeOverlappedNamespaceAttributes() {
  109.       if (((Child)this).getFactory().isProcessNamespace()) {
  110.          for(Node var1 = ((Parent)this).getFirstWithoutReference(); var1 != null; var1 = ((Child)var1).getNextWithoutReference()) {
  111.             if (var1.getNodeType() == 1) {
  112.                ((TXElement)var1).removeOverlappedNamespaceAttributes();
  113.             }
  114.          }
  115.  
  116.       }
  117.    }
  118. }
  119.